home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #6
/
Amiga Plus CD - 2004 - No. 06.iso
/
AmiSoft
/
Misc
/
salv
/
DiskValid.lha
/
DiskValid.c
next >
Wrap
C/C++ Source or Header
|
2004-05-26
|
7KB
|
260 lines
/* DiskValid GUI
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Peter Hutchison
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <string.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/gadtools.h>
#include <proto/graphics.h>
#include <proto/utility.h>
#include "DiskValid.h"
struct Screen *Scr = NULL;
UBYTE *PubScreenName = NULL;
APTR VisualInfo = NULL;
struct Window *DiskValidGUIWnd = NULL;
struct Gadget *DiskValidGUIGList = NULL;
struct IntuiMessage DiskValidGUIMsg;
struct Gadget *DiskValidGUIGadgets[7];
UWORD DiskValidGUILeft = 10;
UWORD DiskValidGUITop = 15;
UWORD DiskValidGUIWidth = 325;
UWORD DiskValidGUIHeight = 244;
UBYTE *DiskValidGUIWdt = (UBYTE *)"DiskValid GUI";
int verbose_flag, fix_flag, analyse_flag, td64_flag;
UBYTE cmd[50];
struct TextAttr topaz8 = {
( STRPTR )"topaz.font", 8, 0x00, 0x01 };
UWORD DiskValidGUIGTypes[] = {
STRING_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
BUTTON_KIND,
BUTTON_KIND
};
struct NewGadget DiskValidGUINGad[] = {
55, 14, 143, 15, (UBYTE *)"Disk", NULL, GD_Disk, PLACETEXT_LEFT, NULL, NULL,
18, 51, 26, 11, (UBYTE *)"Verbose", NULL, GD_Verbose, PLACETEXT_RIGHT, NULL, NULL,
18, 80, 26, 11, (UBYTE *)"Fix", NULL, GD_Fix, PLACETEXT_RIGHT, NULL, NULL,
18, 111, 26, 11, (UBYTE *)"Analyse", NULL, GD_Analyse, PLACETEXT_RIGHT, NULL, NULL,
17, 141, 26, 11, (UBYTE *)"TD64 Support", NULL, GD_TD64_Support, PLACETEXT_RIGHT, NULL, NULL,
15, 193, 99, 24, (UBYTE *)"Start Check", NULL, GD_Start_Check, PLACETEXT_IN, NULL, NULL,
218, 193, 62, 24, (UBYTE *)"Cancel", NULL, GD_Cancel, PLACETEXT_IN, NULL, NULL
};
ULONG DiskValidGUIGTags[] = {
(GTST_String), (ULONG)"DH0:", (GTST_MaxChars), 32, (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE)
};
/* Prototypes */
int SetupScreen(void);
void CloseDownScreen( void );
int HandleDiskValidGUIIDCMP( void );
int Handle_Buttons(struct IntuiMessage *message);
void RunDiskValid(void);
int OpenDiskValidGUIWindow( void );
int CloseDiskValidGUIWindow( void );
/* Program code */
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
int HandleDiskValidGUIIDCMP( void )
{
struct IntuiMessage *m;
BOOL running = TRUE;
while(running ) {
Wait(1L << DiskValidGUIWnd->UserPort->mp_SigBit);
m = GT_GetIMsg( DiskValidGUIWnd->UserPort );
CopyMem(( char * )m, ( char * )&DiskValidGUIMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( DiskValidGUIMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( DiskValidGUIWnd );
GT_EndRefresh( DiskValidGUIWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = CloseDiskValidGUIWindow();
break;
case IDCMP_GADGETUP:
running = Handle_Buttons(m);
break;
}
}
return( running );
}
int Handle_Buttons(struct IntuiMessage *message)
{
struct Gadget *gadget;
UWORD id;
int running = TRUE;
gadget = (struct Gadget *)message->IAddress;
id = gadget->GadgetID;
if (id == GD_Verbose)
verbose_flag = !verbose_flag;
if (id == GD_Fix)
fix_flag = !fix_flag;
if (id == GD_Analyse)
analyse_flag = !analyse_flag;
if (id == GD_TD64_Support)
td64_flag = !td64_flag;
if (id == GD_Start_Check)
RunDiskValid();
if (id == GD_Cancel)
running = FALSE;
return(running);
}
void RunDiskValid(void)
{
BPTR file;
strcpy(cmd,"DiskValid ");
strcat(cmd, ((struct StringInfo *)DiskValidGUIGadgets[0]->SpecialInfo)->Buffer);
if (verbose_flag)
strcat(cmd, " VERBOSE");
if (fix_flag)
strcat(cmd, " FIX");
if (analyse_flag)
strcat(cmd, " ANALYSE");
if (td64_flag)
strcat(cmd, " TD64");
if (file = Open("CON:40/300/300/200/DiskValid/CLOSE/WAIT", MODE_READWRITE)) {
if (!Execute(cmd, NULL, file))
DisplayBeep(Scr);
Close(file);
}
}
int OpenDiskValidGUIWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
if ( ! ( g = CreateContext( &DiskValidGUIGList )))
return( 1L );
for( lc = 0, tc = 0; lc < DiskValidGUI_CNT; lc++ ) {
CopyMem((char * )&DiskValidGUINGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = &topaz8;
ng.ng_LeftEdge += offx;
ng.ng_TopEdge += offy;
DiskValidGUIGadgets[ lc ] = g = CreateGadgetA((ULONG)DiskValidGUIGTypes[ lc ], g, &ng, ( struct TagItem * )&DiskValidGUIGTags[ tc ] );
while( DiskValidGUIGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( DiskValidGUIWnd = OpenWindowTags( NULL,
WA_Left, DiskValidGUILeft,
WA_Top, DiskValidGUITop,
WA_Width, DiskValidGUIWidth,
WA_Height, DiskValidGUIHeight + offy,
WA_IDCMP, STRINGIDCMP|CHECKBOXIDCMP|BUTTONIDCMP|IDCMP_GADGETDOWN|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, DiskValidGUIGList,
WA_Title, DiskValidGUIWdt,
WA_ScreenTitle, "GadToolsBox V2.0b © 1991-1993",
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( DiskValidGUIWnd, NULL );
return( 0L );
}
int CloseDiskValidGUIWindow( void )
{
if ( DiskValidGUIWnd ) {
CloseWindow( DiskValidGUIWnd );
DiskValidGUIWnd = NULL;
}
if ( DiskValidGUIGList ) {
FreeGadgets( DiskValidGUIGList );
DiskValidGUIGList = NULL;
}
return(0);
}
void main(void)
{
SetupScreen();
OpenDiskValidGUIWindow();
HandleDiskValidGUIIDCMP();
CloseDiskValidGUIWindow();
CloseDownScreen();
}